package com.example.plan.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import lombok.Data;

/**
 * 用户收货地址表
 * @TableName user_address
 */
@TableName(value ="user_address")
@Data
public class UserAddress implements Serializable {
    /**
     * 地址ID
     */
    @TableId(value = "address_id", type = IdType.AUTO)
    private Long address_id;

    /**
     * 用户ID
     */
    @TableField(value = "user_id")
    private Long user_id;

    /**
     * 收件人姓名
     */
    @TableField(value = "recipient_name")
    private String recipient_name;

    /**
     * 收件人电话
     */
    @TableField(value = "phone")
    private String phone;

    /**
     * 经纬度坐标（高德地图API生成）
     */
    @TableField(value = "coordinates")
    private Integer coordinates;

    /**
     * 详细地址（如街道门牌号）
     */
    @TableField(value = "detail_address")
    private String detail_address;

    /**
     * 是否为默认地址
     */
    @TableField(value = "is_default")
    private Integer is_default;

    @TableField(exist = false)
    private static final long serialVersionUID = 1L;

    @Override
    public boolean equals(Object that) {
        if (this == that) {
            return true;
        }
        if (that == null) {
            return false;
        }
        if (getClass() != that.getClass()) {
            return false;
        }
        UserAddress other = (UserAddress) that;
        return (this.getAddress_id() == null ? other.getAddress_id() == null : this.getAddress_id().equals(other.getAddress_id()))
            && (this.getUser_id() == null ? other.getUser_id() == null : this.getUser_id().equals(other.getUser_id()))
            && (this.getRecipient_name() == null ? other.getRecipient_name() == null : this.getRecipient_name().equals(other.getRecipient_name()))
            && (this.getPhone() == null ? other.getPhone() == null : this.getPhone().equals(other.getPhone()))
            && (this.getCoordinates() == null ? other.getCoordinates() == null : this.getCoordinates().equals(other.getCoordinates()))
            && (this.getDetail_address() == null ? other.getDetail_address() == null : this.getDetail_address().equals(other.getDetail_address()))
            && (this.getIs_default() == null ? other.getIs_default() == null : this.getIs_default().equals(other.getIs_default()));
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((getAddress_id() == null) ? 0 : getAddress_id().hashCode());
        result = prime * result + ((getUser_id() == null) ? 0 : getUser_id().hashCode());
        result = prime * result + ((getRecipient_name() == null) ? 0 : getRecipient_name().hashCode());
        result = prime * result + ((getPhone() == null) ? 0 : getPhone().hashCode());
        result = prime * result + ((getCoordinates() == null) ? 0 : getCoordinates().hashCode());
        result = prime * result + ((getDetail_address() == null) ? 0 : getDetail_address().hashCode());
        result = prime * result + ((getIs_default() == null) ? 0 : getIs_default().hashCode());
        return result;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(getClass().getSimpleName());
        sb.append(" [");
        sb.append("Hash = ").append(hashCode());
        sb.append(", address_id=").append(address_id);
        sb.append(", user_id=").append(user_id);
        sb.append(", recipient_name=").append(recipient_name);
        sb.append(", phone=").append(phone);
        sb.append(", coordinates=").append(coordinates);
        sb.append(", detail_address=").append(detail_address);
        sb.append(", is_default=").append(is_default);
        sb.append(", serialVersionUID=").append(serialVersionUID);
        sb.append("]");
        return sb.toString();
    }
}